#pragma once
#include <iostream>
#include <memory>

using namespace std;

int* func1()
{
	int* a1 = new int;
	*a1 = 10;
	return a1;
}
int* func2()
{
	int* a2 = new int;
	*a2 = 10;
	return a2;
}
shared_ptr<int> func4()
{
	const shared_ptr<int> a2(new int);
	*a2 = 10;
	return a2;
}

int main()
{
	int* a1 = func1();
	int* a2 = func2();

	cout << *a1 << endl;
	cout << *a2 << endl;

	shared_ptr<int> const b1(new int);
	shared_ptr<int> b3(b1);
	*b1 = 10;
	cout << *b1<<' '<< b1 << endl;
	*b3 = 10;
	cout << *b3 << ' ' << b3 << endl;

	shared_ptr<int> b2 = func4();
	cout << *b2 << ' ' << b2 << endl;


	cout << endl;
	cout << endl;

	cout << b2 .use_count()<< endl;
	weak_ptr<int> c1 = b1;
	cout << b2.use_count() << endl;
	cout << c1.use_count() << endl;


	return 0;
}

